package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.BsEntouragePresets;
import com.ruoyi.system.service.IBsEntouragePresetsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 副将预设Controller
 * 
 * @author ruoyi
 * @date 2025-08-14
 */
@RestController
@RequestMapping("/system/EntouragePresets")
public class BsEntouragePresetsController extends BaseController
{
    @Autowired
    private IBsEntouragePresetsService bsEntouragePresetsService;

    /**
     * 查询副将预设列表
     */
    @PreAuthorize("@ss.hasPermi('system:presets:list')")
    @GetMapping("/list")
    public TableDataInfo list(BsEntouragePresets bsEntouragePresets)
    {
        startPage();
        List<BsEntouragePresets> list = bsEntouragePresetsService.selectBsEntouragePresetsList(bsEntouragePresets);
        return getDataTable(list);
    }

    /**
     * 导出副将预设列表
     */
    @PreAuthorize("@ss.hasPermi('system:presets:export')")
    @Log(title = "副将预设", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BsEntouragePresets bsEntouragePresets)
    {
        List<BsEntouragePresets> list = bsEntouragePresetsService.selectBsEntouragePresetsList(bsEntouragePresets);
        ExcelUtil<BsEntouragePresets> util = new ExcelUtil<BsEntouragePresets>(BsEntouragePresets.class);
        util.exportExcel(response, list, "副将预设数据");
    }

    /**
     * 获取副将预设详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:presets:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(bsEntouragePresetsService.selectBsEntouragePresetsById(id));
    }

    /**
     * 新增副将预设
     */
    @PreAuthorize("@ss.hasPermi('system:presets:add')")
    @Log(title = "副将预设", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BsEntouragePresets bsEntouragePresets)
    {
        return toAjax(bsEntouragePresetsService.insertBsEntouragePresets(bsEntouragePresets));
    }

    /**
     * 修改副将预设
     */
    @PreAuthorize("@ss.hasPermi('system:presets:edit')")
    @Log(title = "副将预设", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BsEntouragePresets bsEntouragePresets)
    {
        return toAjax(bsEntouragePresetsService.updateBsEntouragePresets(bsEntouragePresets));
    }

    /**
     * 删除副将预设
     */
    @PreAuthorize("@ss.hasPermi('system:presets:remove')")
    @Log(title = "副将预设", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(bsEntouragePresetsService.deleteBsEntouragePresetsByIds(ids));
    }
}
